//
//  BiSaleApplyViewController.m
//  TrunkIndustryManageSystem
//
//  Created by WT_lyy on 15/4/21.
//  Copyright (c) 2015年 李璐西. All rights reserved.
//

#import "BiSaleApplyViewController.h"

@interface BiSaleApplyViewController ()<UITextFieldDelegate,UITextViewDelegate>{

    
    __weak IBOutlet UIScrollView *_scrollView;
}

@property (weak, nonatomic) IBOutlet UILabel *labAppler;
@property (weak, nonatomic) IBOutlet UILabel *labcarType;
@property (weak, nonatomic) IBOutlet UILabel *labStarttime;
@property (weak, nonatomic) IBOutlet UILabel *labReturnTime;

@property (weak, nonatomic) IBOutlet UITextField *textfDes;
@property (weak, nonatomic) IBOutlet UITextField *textfCarNum;

@property (weak, nonatomic) IBOutlet UITextField *tetxfCost;
@property (weak, nonatomic) IBOutlet UITextField *textfKilometer;
@property (weak, nonatomic) IBOutlet UITextField *textfJoiner;
@property (weak, nonatomic) IBOutlet UITextView *textvRemark;
@property (weak, nonatomic) IBOutlet UITextView *tetxvReason;
@end

@implementation BiSaleApplyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavBackBtn];
    
    [self setNavBarTitle:@"申请行销"];
    
    [self setNavBarWithHidden:NO];

    [self addTestView];
    
    _scrollView.contentSize = CGSizeMake(320, 600);
    
    self.labAppler.text = [BiUserEntity sharedInstance].name;
    
    self.textvRemark.layer.borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:100.0].CGColor;
    self.textvRemark.layer.borderWidth = 0.5;
    
    self.tetxvReason.layer.borderColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:100.0].CGColor;
    self.tetxvReason.layer.borderWidth = 0.5;
}


#pragma -mark  UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    
    return YES;
}



#pragma -mark  UITextFieldDelegate
- (void)textViewDidBeginEditing:(UITextView *)textView{


}


- (void)textViewDidEndEditing:(UITextView *)textView{

    
}

#pragma -mark Btn Action
- (IBAction)btnClick:(UIButton *)sender {
    
    if (0 == sender.tag) {
        
        NSDictionary * paraDic = [NSDictionary dictionaryWithObjectsAndKeys:@"0",@"id",
                                  [BiUserEntity sharedInstance].userid,@"userApplyId",
                                  self.textfJoiner.text,@"participant",
                                  self.textfDes.text,@"destination",
                                  @"2015-04-20 13:10",@"gooffTime",
                                  @"1",@"useCarType",
                                  self.textfCarNum.text,@"licensePlate",
                                  @"2015-04-21 12:22",@"returnTime",
                                  self.textfKilometer.text,@"kilometre",
                                  self.tetxfCost.text,@"fee",
                                  self.textvRemark.text,@"remark",
                                  self.tetxvReason.text,@"xingxiaoRejectReason",
                                  @"0",@"status",
                                  nil];
    
        [[BiNetEngine shareInstance] requestSaleApplySave:self paraDict:paraDic];
        
        [self asyshowHUDView:WAITING CurrentView:self];
        
    }else if(1 == sender.tag){
    
        [self showAlertView:@"亲，请先保存再审核！"];
    
    }
}

- (IBAction)btnInputClick:(UIButton *)sender {
    
    if (10 == sender.tag) {
        
        
    }else if (11 == sender.tag){
    
        
    }else if (12 == sender.tag){
    
    
    }
}

#pragma -mark Net Delegate
- (void)onNetEngineResponse:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    
    NSDictionary * dict = (NSDictionary *)entity;
    
    if ([dict[@"response_status"] integerValue] != 200) {
        
        [self showAlertView:dict[@"result_info"]];
        
        return;
        
    }
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)onNetEngineResponseFail:(int)tag entity:(id)entity userInfo:(NSDictionary *)userInfo
{
    [self removeHUDView:self];
    
}


@end
